/**
 * hex 转 rgb
 * @param {string} str 
 * @returns 
 */
function hexToRgb(str) {
  str = str.replace('#', '')
  let hexs = str.match(/../g)
  for (let i = 0; i < 3; i++) {
    hexs[i] = parseInt(hexs[i], 16)
  }
  return hexs
}

export default {
  computed: {
    themeColor: {
      get() {
        return this.$store.state.common.themeColor
      },
      set(val) {
        this.$store.commit('common/updatethemeColor', val)
      }
    },
    themeBorderColor() {
      return `rgba(${hexToRgb(this.themeColor).join(',')}, 0.2)`
    },
    themeBackgroundColor: {
      get() {
        return this.$store.state.common.themeBackgroundColor
      },
      set(val) {
        this.$store.commit('common/updatethemeBackgroundColor', val)
      }
    }
  }
}